package Utility;

import Context.Context;
import Context.ContextHolder;

/**
 * @category Utility module
 * @author Sean Lionheart
 * @version 1.0.0.0
 * The log enable filter which indicates a filter is enabled.
 */
abstract class LogFilterEnable implements ILogFilter {
	protected boolean enable;
	
	/**
	 * Initialize the filter according to the configuration.
	 */
	protected LogFilterEnable() {
		Context ctx = ContextHolder.getContext();
		String stringEnalbe = ctx.getProperty(this.getClass().getName());
		if(stringEnalbe.equals(LogContext.ENABLE)) {
			enable = true;
		}
		else {
			enable = false;
		}
	}
	/**
	 * The entry can pass the filter if and only if the filter is enabled.
	 */
	public boolean filtrateLog(LogEntry entry) {
		return enable;
	}
}
